<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xdb="http://orbeon.org/oxf/xml/xmldb" xmlns:xu="http://www.xmldb.org/xupdate">
	
	<p:param type="input" name="instance"/>
	<p:param type="output" name="data"/>

	<p:processor name="oxf:pipeline">
		<p:input name="config" href="../session.xpl"/>
		<p:output name="data" id="session"/>
	</p:processor>
	<p:processor name="oxf:xslt">
		<p:input name="data" href="#session"/>
		<p:input name="error" href="#instance"/>
		<p:output name="data" id="query"/>
		<p:input name="config">
			<xdb:query collection="/db/portal" xsl:version="2.0">
				<xsl:text>xquery version "1.0";</xsl:text>
				<list>
					<xsl:copy-of select="doc('input:error')"/>
					<new>
						<name/>
						<description/>
					</new>
					{for $g in /groups/group[not(exists(members/member/@id = '<xsl:value-of select="/session/username"/>')) and @id != 'gr_0'] return
					element group{
						attribute id{$g/@id},
						attribute join{'false'},
						$g/name,
						$g/description,
						$g/members,
						element widgets{
							for $w in $g/interface/widget return
								element widget{
									/widgetsList/category/widget[@id=$w/@id]/name/text()
								}
						}
					}
				}</list>
			</xdb:query>
		</p:input>
	</p:processor>

	<!--Get Groups-->
	<p:processor name="oxf:xmldb-query">
		<p:input name="datasource" href="/config/datasource.xml"/>
		<p:input name="query" href="#query"/>
		<p:output name="data" ref="data"/>
	</p:processor>


</p:config>